<template>
	<div class="icons">
		<swiper :options="swiperOptions">
			<swiper-slide v-for="(page,index) of pages" :key="index">
				<div class="iconsbox" v-for="item of page" :key="item.id">
					<div class="imgcontent">
						<img class="iconsimg" :src="item.imgUrl">
					</div>
					<span class="desc">{{item.desc}}</span>
				</div>
			</swiper-slide>
			<div class="swiper-pagination"  slot="pagination"></div>
		</swiper>
	</div>
</template>

<script>
export default{
	props:{
		icon:Array
	},
	data (){
		return{
			swiperOptions:{
				pagination:{
					el:'.swiper-pagination',
    		        loop:true,
                     speed: 400,
				}
			}
		}
	},
	computed:{
		pages (){
			const pages=[]
			this.icon.forEach((item,index)=>{
				const page=Math.floor(index/8)
				if(!pages[page]){
					pages[page]=[]
				}
				pages[page].push(item)
			})
			return pages
		}
	}
}
</script>

<style lang="stylus" scoped>
.icons >>> .swiper-pagination-bullet-active
 background:yellow
.icons
 width:100%
 height:4rem
 overflow:hidden
 border-bottom:.01rem solid #eee
 padding-bottom:.3rem

.iconsbox 
 width:25%
 height:1.78rem
 float:left
 text-align:center
 margin-bottom:.2rem
 padding-bottom:.2rem

.imgcontent
 width:1.5rem
 height:1.3rem
 margin:0 auto
.iconsimg
 width:1.2rem
 height:1.2rem
 padding-top:.1rem
.desc
 display:block
 text-align:center
 font-size:.32rem
 padding:.1rem 0

</style>